package learn.euraka.service.web.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author： xiami
 * @Date： Created in 2018-03-25 22:27
 * @Modified By：
 */
@RestController
public class ComputeController {

    @Resource
    ServiceInstance instance;

    private static Logger logger = LoggerFactory.getLogger(ComputeController.class);

    @GetMapping("/add")
    public Integer add(@RequestParam Integer a, @RequestParam Integer b) {
        int r = a + b;
        logger.info("/add, host:" + instance.getHost() + ", service_id:" + instance.getServiceId() + ", result:" + r);
        return r;
    }


}
